/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/**
 * Autogenerated by Thrift Compiler (0.11.0)
 *
 * <p>DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *
 * @generated
 */
package org.apache.pegasus.replication;

import org.apache.pegasus.base.gpid;
import org.apache.pegasus.base.rpc_address;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(
    value = "Autogenerated by Thrift Compiler (0.11.0)",
    date = "2020-04-13")
public class partition_configuration
    implements org.apache.thrift.TBase<partition_configuration, partition_configuration._Fields>,
        java.io.Serializable,
        Cloneable,
        Comparable<partition_configuration> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC =
      new org.apache.thrift.protocol.TStruct("partition_configuration");

  private static final org.apache.thrift.protocol.TField PID_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "pid", org.apache.thrift.protocol.TType.STRUCT, (short) 1);
  private static final org.apache.thrift.protocol.TField BALLOT_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "ballot", org.apache.thrift.protocol.TType.I64, (short) 2);
  private static final org.apache.thrift.protocol.TField MAX_REPLICA_COUNT_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "max_replica_count", org.apache.thrift.protocol.TType.I32, (short) 3);
  private static final org.apache.thrift.protocol.TField PRIMARY_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "primary", org.apache.thrift.protocol.TType.STRUCT, (short) 4);
  private static final org.apache.thrift.protocol.TField SECONDARIES_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "secondaries", org.apache.thrift.protocol.TType.LIST, (short) 5);
  private static final org.apache.thrift.protocol.TField LAST_DROPS_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "last_drops", org.apache.thrift.protocol.TType.LIST, (short) 6);
  private static final org.apache.thrift.protocol.TField LAST_COMMITTED_DECREE_FIELD_DESC =
      new org.apache.thrift.protocol.TField(
          "last_committed_decree", org.apache.thrift.protocol.TType.I64, (short) 7);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY =
      new partition_configurationStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY =
      new partition_configurationTupleSchemeFactory();

  public gpid pid; // required
  public long ballot; // required
  public int max_replica_count; // required
  public rpc_address primary; // required
  public java.util.List<rpc_address> secondaries; // required
  public java.util.List<rpc_address> last_drops; // required
  public long last_committed_decree; // required

  /**
   * The set of fields this struct contains, along with convenience methods for finding and
   * manipulating them.
   */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    PID((short) 1, "pid"),
    BALLOT((short) 2, "ballot"),
    MAX_REPLICA_COUNT((short) 3, "max_replica_count"),
    PRIMARY((short) 4, "primary"),
    SECONDARIES((short) 5, "secondaries"),
    LAST_DROPS((short) 6, "last_drops"),
    LAST_COMMITTED_DECREE((short) 7, "last_committed_decree");

    private static final java.util.Map<java.lang.String, _Fields> byName =
        new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /** Find the _Fields constant that matches fieldId, or null if its not found. */
    public static _Fields findByThriftId(int fieldId) {
      switch (fieldId) {
        case 1: // PID
          return PID;
        case 2: // BALLOT
          return BALLOT;
        case 3: // MAX_REPLICA_COUNT
          return MAX_REPLICA_COUNT;
        case 4: // PRIMARY
          return PRIMARY;
        case 5: // SECONDARIES
          return SECONDARIES;
        case 6: // LAST_DROPS
          return LAST_DROPS;
        case 7: // LAST_COMMITTED_DECREE
          return LAST_COMMITTED_DECREE;
        default:
          return null;
      }
    }

    /** Find the _Fields constant that matches fieldId, throwing an exception if it is not found. */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null)
        throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /** Find the _Fields constant that matches name, or null if its not found. */
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __BALLOT_ISSET_ID = 0;
  private static final int __MAX_REPLICA_COUNT_ISSET_ID = 1;
  private static final int __LAST_COMMITTED_DECREE_ISSET_ID = 2;
  private byte __isset_bitfield = 0;
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;

  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap =
        new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(
        _Fields.PID,
        new org.apache.thrift.meta_data.FieldMetaData(
            "pid",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.StructMetaData(
                org.apache.thrift.protocol.TType.STRUCT, gpid.class)));
    tmpMap.put(
        _Fields.BALLOT,
        new org.apache.thrift.meta_data.FieldMetaData(
            "ballot",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.FieldValueMetaData(
                org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(
        _Fields.MAX_REPLICA_COUNT,
        new org.apache.thrift.meta_data.FieldMetaData(
            "max_replica_count",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.FieldValueMetaData(
                org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(
        _Fields.PRIMARY,
        new org.apache.thrift.meta_data.FieldMetaData(
            "primary",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.StructMetaData(
                org.apache.thrift.protocol.TType.STRUCT, rpc_address.class)));
    tmpMap.put(
        _Fields.SECONDARIES,
        new org.apache.thrift.meta_data.FieldMetaData(
            "secondaries",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.ListMetaData(
                org.apache.thrift.protocol.TType.LIST,
                new org.apache.thrift.meta_data.StructMetaData(
                    org.apache.thrift.protocol.TType.STRUCT, rpc_address.class))));
    tmpMap.put(
        _Fields.LAST_DROPS,
        new org.apache.thrift.meta_data.FieldMetaData(
            "last_drops",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.ListMetaData(
                org.apache.thrift.protocol.TType.LIST,
                new org.apache.thrift.meta_data.StructMetaData(
                    org.apache.thrift.protocol.TType.STRUCT, rpc_address.class))));
    tmpMap.put(
        _Fields.LAST_COMMITTED_DECREE,
        new org.apache.thrift.meta_data.FieldMetaData(
            "last_committed_decree",
            org.apache.thrift.TFieldRequirementType.DEFAULT,
            new org.apache.thrift.meta_data.FieldValueMetaData(
                org.apache.thrift.protocol.TType.I64)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(
        partition_configuration.class, metaDataMap);
  }

  public partition_configuration() {}

  public partition_configuration(
      gpid pid,
      long ballot,
      int max_replica_count,
      rpc_address primary,
      java.util.List<rpc_address> secondaries,
      java.util.List<rpc_address> last_drops,
      long last_committed_decree) {
    this();
    this.pid = pid;
    this.ballot = ballot;
    setBallotIsSet(true);
    this.max_replica_count = max_replica_count;
    setMax_replica_countIsSet(true);
    this.primary = primary;
    this.secondaries = secondaries;
    this.last_drops = last_drops;
    this.last_committed_decree = last_committed_decree;
    setLast_committed_decreeIsSet(true);
  }

  /** Performs a deep copy on <i>other</i>. */
  public partition_configuration(partition_configuration other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetPid()) {
      this.pid = new gpid(other.pid);
    }
    this.ballot = other.ballot;
    this.max_replica_count = other.max_replica_count;
    if (other.isSetPrimary()) {
      this.primary = new rpc_address(other.primary);
    }
    if (other.isSetSecondaries()) {
      java.util.List<rpc_address> __this__secondaries =
          new java.util.ArrayList<rpc_address>(other.secondaries.size());
      for (rpc_address other_element : other.secondaries) {
        __this__secondaries.add(new rpc_address(other_element));
      }
      this.secondaries = __this__secondaries;
    }
    if (other.isSetLast_drops()) {
      java.util.List<rpc_address> __this__last_drops =
          new java.util.ArrayList<rpc_address>(other.last_drops.size());
      for (rpc_address other_element : other.last_drops) {
        __this__last_drops.add(new rpc_address(other_element));
      }
      this.last_drops = __this__last_drops;
    }
    this.last_committed_decree = other.last_committed_decree;
  }

  public partition_configuration deepCopy() {
    return new partition_configuration(this);
  }

  @Override
  public void clear() {
    this.pid = null;
    setBallotIsSet(false);
    this.ballot = 0;
    setMax_replica_countIsSet(false);
    this.max_replica_count = 0;
    this.primary = null;
    this.secondaries = null;
    this.last_drops = null;
    setLast_committed_decreeIsSet(false);
    this.last_committed_decree = 0;
  }

  public gpid getPid() {
    return this.pid;
  }

  public partition_configuration setPid(gpid pid) {
    this.pid = pid;
    return this;
  }

  public void unsetPid() {
    this.pid = null;
  }

  /** Returns true if field pid is set (has been assigned a value) and false otherwise */
  public boolean isSetPid() {
    return this.pid != null;
  }

  public void setPidIsSet(boolean value) {
    if (!value) {
      this.pid = null;
    }
  }

  public long getBallot() {
    return this.ballot;
  }

  public partition_configuration setBallot(long ballot) {
    this.ballot = ballot;
    setBallotIsSet(true);
    return this;
  }

  public void unsetBallot() {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __BALLOT_ISSET_ID);
  }

  /** Returns true if field ballot is set (has been assigned a value) and false otherwise */
  public boolean isSetBallot() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __BALLOT_ISSET_ID);
  }

  public void setBallotIsSet(boolean value) {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __BALLOT_ISSET_ID, value);
  }

  public int getMax_replica_count() {
    return this.max_replica_count;
  }

  public partition_configuration setMax_replica_count(int max_replica_count) {
    this.max_replica_count = max_replica_count;
    setMax_replica_countIsSet(true);
    return this;
  }

  public void unsetMax_replica_count() {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __MAX_REPLICA_COUNT_ISSET_ID);
  }

  /**
   * Returns true if field max_replica_count is set (has been assigned a value) and false otherwise
   */
  public boolean isSetMax_replica_count() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __MAX_REPLICA_COUNT_ISSET_ID);
  }

  public void setMax_replica_countIsSet(boolean value) {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.setBit(
            __isset_bitfield, __MAX_REPLICA_COUNT_ISSET_ID, value);
  }

  public rpc_address getPrimary() {
    return this.primary;
  }

  public partition_configuration setPrimary(rpc_address primary) {
    this.primary = primary;
    return this;
  }

  public void unsetPrimary() {
    this.primary = null;
  }

  /** Returns true if field primary is set (has been assigned a value) and false otherwise */
  public boolean isSetPrimary() {
    return this.primary != null;
  }

  public void setPrimaryIsSet(boolean value) {
    if (!value) {
      this.primary = null;
    }
  }

  public int getSecondariesSize() {
    return (this.secondaries == null) ? 0 : this.secondaries.size();
  }

  public java.util.Iterator<rpc_address> getSecondariesIterator() {
    return (this.secondaries == null) ? null : this.secondaries.iterator();
  }

  public void addToSecondaries(rpc_address elem) {
    if (this.secondaries == null) {
      this.secondaries = new java.util.ArrayList<rpc_address>();
    }
    this.secondaries.add(elem);
  }

  public java.util.List<rpc_address> getSecondaries() {
    return this.secondaries;
  }

  public partition_configuration setSecondaries(java.util.List<rpc_address> secondaries) {
    this.secondaries = secondaries;
    return this;
  }

  public void unsetSecondaries() {
    this.secondaries = null;
  }

  /** Returns true if field secondaries is set (has been assigned a value) and false otherwise */
  public boolean isSetSecondaries() {
    return this.secondaries != null;
  }

  public void setSecondariesIsSet(boolean value) {
    if (!value) {
      this.secondaries = null;
    }
  }

  public int getLast_dropsSize() {
    return (this.last_drops == null) ? 0 : this.last_drops.size();
  }

  public java.util.Iterator<rpc_address> getLast_dropsIterator() {
    return (this.last_drops == null) ? null : this.last_drops.iterator();
  }

  public void addToLast_drops(rpc_address elem) {
    if (this.last_drops == null) {
      this.last_drops = new java.util.ArrayList<rpc_address>();
    }
    this.last_drops.add(elem);
  }

  public java.util.List<rpc_address> getLast_drops() {
    return this.last_drops;
  }

  public partition_configuration setLast_drops(java.util.List<rpc_address> last_drops) {
    this.last_drops = last_drops;
    return this;
  }

  public void unsetLast_drops() {
    this.last_drops = null;
  }

  /** Returns true if field last_drops is set (has been assigned a value) and false otherwise */
  public boolean isSetLast_drops() {
    return this.last_drops != null;
  }

  public void setLast_dropsIsSet(boolean value) {
    if (!value) {
      this.last_drops = null;
    }
  }

  public long getLast_committed_decree() {
    return this.last_committed_decree;
  }

  public partition_configuration setLast_committed_decree(long last_committed_decree) {
    this.last_committed_decree = last_committed_decree;
    setLast_committed_decreeIsSet(true);
    return this;
  }

  public void unsetLast_committed_decree() {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.clearBit(
            __isset_bitfield, __LAST_COMMITTED_DECREE_ISSET_ID);
  }

  /**
   * Returns true if field last_committed_decree is set (has been assigned a value) and false
   * otherwise
   */
  public boolean isSetLast_committed_decree() {
    return org.apache.thrift.EncodingUtils.testBit(
        __isset_bitfield, __LAST_COMMITTED_DECREE_ISSET_ID);
  }

  public void setLast_committed_decreeIsSet(boolean value) {
    __isset_bitfield =
        org.apache.thrift.EncodingUtils.setBit(
            __isset_bitfield, __LAST_COMMITTED_DECREE_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, java.lang.Object value) {
    switch (field) {
      case PID:
        if (value == null) {
          unsetPid();
        } else {
          setPid((gpid) value);
        }
        break;

      case BALLOT:
        if (value == null) {
          unsetBallot();
        } else {
          setBallot((java.lang.Long) value);
        }
        break;

      case MAX_REPLICA_COUNT:
        if (value == null) {
          unsetMax_replica_count();
        } else {
          setMax_replica_count((java.lang.Integer) value);
        }
        break;

      case PRIMARY:
        if (value == null) {
          unsetPrimary();
        } else {
          setPrimary((rpc_address) value);
        }
        break;

      case SECONDARIES:
        if (value == null) {
          unsetSecondaries();
        } else {
          setSecondaries((java.util.List<rpc_address>) value);
        }
        break;

      case LAST_DROPS:
        if (value == null) {
          unsetLast_drops();
        } else {
          setLast_drops((java.util.List<rpc_address>) value);
        }
        break;

      case LAST_COMMITTED_DECREE:
        if (value == null) {
          unsetLast_committed_decree();
        } else {
          setLast_committed_decree((java.lang.Long) value);
        }
        break;
    }
  }

  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
      case PID:
        return getPid();

      case BALLOT:
        return getBallot();

      case MAX_REPLICA_COUNT:
        return getMax_replica_count();

      case PRIMARY:
        return getPrimary();

      case SECONDARIES:
        return getSecondaries();

      case LAST_DROPS:
        return getLast_drops();

      case LAST_COMMITTED_DECREE:
        return getLast_committed_decree();
    }
    throw new java.lang.IllegalStateException();
  }

  /**
   * Returns true if field corresponding to fieldID is set (has been assigned a value) and false
   * otherwise
   */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
      case PID:
        return isSetPid();
      case BALLOT:
        return isSetBallot();
      case MAX_REPLICA_COUNT:
        return isSetMax_replica_count();
      case PRIMARY:
        return isSetPrimary();
      case SECONDARIES:
        return isSetSecondaries();
      case LAST_DROPS:
        return isSetLast_drops();
      case LAST_COMMITTED_DECREE:
        return isSetLast_committed_decree();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that == null) return false;
    if (that instanceof partition_configuration) return this.equals((partition_configuration) that);
    return false;
  }

  public boolean equals(partition_configuration that) {
    if (that == null) return false;
    if (this == that) return true;

    boolean this_present_pid = true && this.isSetPid();
    boolean that_present_pid = true && that.isSetPid();
    if (this_present_pid || that_present_pid) {
      if (!(this_present_pid && that_present_pid)) return false;
      if (!this.pid.equals(that.pid)) return false;
    }

    boolean this_present_ballot = true;
    boolean that_present_ballot = true;
    if (this_present_ballot || that_present_ballot) {
      if (!(this_present_ballot && that_present_ballot)) return false;
      if (this.ballot != that.ballot) return false;
    }

    boolean this_present_max_replica_count = true;
    boolean that_present_max_replica_count = true;
    if (this_present_max_replica_count || that_present_max_replica_count) {
      if (!(this_present_max_replica_count && that_present_max_replica_count)) return false;
      if (this.max_replica_count != that.max_replica_count) return false;
    }

    boolean this_present_primary = true && this.isSetPrimary();
    boolean that_present_primary = true && that.isSetPrimary();
    if (this_present_primary || that_present_primary) {
      if (!(this_present_primary && that_present_primary)) return false;
      if (!this.primary.equals(that.primary)) return false;
    }

    boolean this_present_secondaries = true && this.isSetSecondaries();
    boolean that_present_secondaries = true && that.isSetSecondaries();
    if (this_present_secondaries || that_present_secondaries) {
      if (!(this_present_secondaries && that_present_secondaries)) return false;
      if (!this.secondaries.equals(that.secondaries)) return false;
    }

    boolean this_present_last_drops = true && this.isSetLast_drops();
    boolean that_present_last_drops = true && that.isSetLast_drops();
    if (this_present_last_drops || that_present_last_drops) {
      if (!(this_present_last_drops && that_present_last_drops)) return false;
      if (!this.last_drops.equals(that.last_drops)) return false;
    }

    boolean this_present_last_committed_decree = true;
    boolean that_present_last_committed_decree = true;
    if (this_present_last_committed_decree || that_present_last_committed_decree) {
      if (!(this_present_last_committed_decree && that_present_last_committed_decree)) return false;
      if (this.last_committed_decree != that.last_committed_decree) return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetPid()) ? 131071 : 524287);
    if (isSetPid()) hashCode = hashCode * 8191 + pid.hashCode();

    hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(ballot);

    hashCode = hashCode * 8191 + max_replica_count;

    hashCode = hashCode * 8191 + ((isSetPrimary()) ? 131071 : 524287);
    if (isSetPrimary()) hashCode = hashCode * 8191 + primary.hashCode();

    hashCode = hashCode * 8191 + ((isSetSecondaries()) ? 131071 : 524287);
    if (isSetSecondaries()) hashCode = hashCode * 8191 + secondaries.hashCode();

    hashCode = hashCode * 8191 + ((isSetLast_drops()) ? 131071 : 524287);
    if (isSetLast_drops()) hashCode = hashCode * 8191 + last_drops.hashCode();

    hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(last_committed_decree);

    return hashCode;
  }

  @Override
  public int compareTo(partition_configuration other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetPid()).compareTo(other.isSetPid());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPid()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pid, other.pid);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetBallot()).compareTo(other.isSetBallot());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBallot()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ballot, other.ballot);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetMax_replica_count())
            .compareTo(other.isSetMax_replica_count());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMax_replica_count()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(this.max_replica_count, other.max_replica_count);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetPrimary()).compareTo(other.isSetPrimary());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPrimary()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.primary, other.primary);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetSecondaries()).compareTo(other.isSetSecondaries());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSecondaries()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.secondaries, other.secondaries);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetLast_drops()).compareTo(other.isSetLast_drops());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLast_drops()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.last_drops, other.last_drops);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison =
        java.lang.Boolean.valueOf(isSetLast_committed_decree())
            .compareTo(other.isSetLast_committed_decree());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLast_committed_decree()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(
              this.last_committed_decree, other.last_committed_decree);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot)
      throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("partition_configuration(");
    boolean first = true;

    sb.append("pid:");
    if (this.pid == null) {
      sb.append("null");
    } else {
      sb.append(this.pid);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("ballot:");
    sb.append(this.ballot);
    first = false;
    if (!first) sb.append(", ");
    sb.append("max_replica_count:");
    sb.append(this.max_replica_count);
    first = false;
    if (!first) sb.append(", ");
    sb.append("primary:");
    if (this.primary == null) {
      sb.append("null");
    } else {
      sb.append(this.primary);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("secondaries:");
    if (this.secondaries == null) {
      sb.append("null");
    } else {
      sb.append(this.secondaries);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("last_drops:");
    if (this.last_drops == null) {
      sb.append("null");
    } else {
      sb.append(this.last_drops);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("last_committed_decree:");
    sb.append(this.last_committed_decree);
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
    if (pid != null) {
      pid.validate();
    }
    if (primary != null) {
      primary.validate();
    }
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(
          new org.apache.thrift.protocol.TCompactProtocol(
              new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in)
      throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and
      // doesn't call the default constructor.
      __isset_bitfield = 0;
      read(
          new org.apache.thrift.protocol.TCompactProtocol(
              new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class partition_configurationStandardSchemeFactory
      implements org.apache.thrift.scheme.SchemeFactory {
    public partition_configurationStandardScheme getScheme() {
      return new partition_configurationStandardScheme();
    }
  }

  private static class partition_configurationStandardScheme
      extends org.apache.thrift.scheme.StandardScheme<partition_configuration> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, partition_configuration struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true) {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
          break;
        }
        switch (schemeField.id) {
          case 1: // PID
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.pid = new gpid();
              struct.pid.read(iprot);
              struct.setPidIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // BALLOT
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.ballot = iprot.readI64();
              struct.setBallotIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // MAX_REPLICA_COUNT
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.max_replica_count = iprot.readI32();
              struct.setMax_replica_countIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // PRIMARY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.primary = new rpc_address();
              struct.primary.read(iprot);
              struct.setPrimaryIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // SECONDARIES
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
                struct.secondaries = new java.util.ArrayList<rpc_address>(_list0.size);
                rpc_address _elem1;
                for (int _i2 = 0; _i2 < _list0.size; ++_i2) {
                  _elem1 = new rpc_address();
                  _elem1.read(iprot);
                  struct.secondaries.add(_elem1);
                }
                iprot.readListEnd();
              }
              struct.setSecondariesIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // LAST_DROPS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list3 = iprot.readListBegin();
                struct.last_drops = new java.util.ArrayList<rpc_address>(_list3.size);
                rpc_address _elem4;
                for (int _i5 = 0; _i5 < _list3.size; ++_i5) {
                  _elem4 = new rpc_address();
                  _elem4.read(iprot);
                  struct.last_drops.add(_elem4);
                }
                iprot.readListEnd();
              }
              struct.setLast_dropsIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // LAST_COMMITTED_DECREE
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.last_committed_decree = iprot.readI64();
              struct.setLast_committed_decreeIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, partition_configuration struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.pid != null) {
        oprot.writeFieldBegin(PID_FIELD_DESC);
        struct.pid.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(BALLOT_FIELD_DESC);
      oprot.writeI64(struct.ballot);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(MAX_REPLICA_COUNT_FIELD_DESC);
      oprot.writeI32(struct.max_replica_count);
      oprot.writeFieldEnd();
      if (struct.primary != null) {
        oprot.writeFieldBegin(PRIMARY_FIELD_DESC);
        struct.primary.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.secondaries != null) {
        oprot.writeFieldBegin(SECONDARIES_FIELD_DESC);
        {
          oprot.writeListBegin(
              new org.apache.thrift.protocol.TList(
                  org.apache.thrift.protocol.TType.STRUCT, struct.secondaries.size()));
          for (rpc_address _iter6 : struct.secondaries) {
            _iter6.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.last_drops != null) {
        oprot.writeFieldBegin(LAST_DROPS_FIELD_DESC);
        {
          oprot.writeListBegin(
              new org.apache.thrift.protocol.TList(
                  org.apache.thrift.protocol.TType.STRUCT, struct.last_drops.size()));
          for (rpc_address _iter7 : struct.last_drops) {
            _iter7.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(LAST_COMMITTED_DECREE_FIELD_DESC);
      oprot.writeI64(struct.last_committed_decree);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
  }

  private static class partition_configurationTupleSchemeFactory
      implements org.apache.thrift.scheme.SchemeFactory {
    public partition_configurationTupleScheme getScheme() {
      return new partition_configurationTupleScheme();
    }
  }

  private static class partition_configurationTupleScheme
      extends org.apache.thrift.scheme.TupleScheme<partition_configuration> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, partition_configuration struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot =
          (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetPid()) {
        optionals.set(0);
      }
      if (struct.isSetBallot()) {
        optionals.set(1);
      }
      if (struct.isSetMax_replica_count()) {
        optionals.set(2);
      }
      if (struct.isSetPrimary()) {
        optionals.set(3);
      }
      if (struct.isSetSecondaries()) {
        optionals.set(4);
      }
      if (struct.isSetLast_drops()) {
        optionals.set(5);
      }
      if (struct.isSetLast_committed_decree()) {
        optionals.set(6);
      }
      oprot.writeBitSet(optionals, 7);
      if (struct.isSetPid()) {
        struct.pid.write(oprot);
      }
      if (struct.isSetBallot()) {
        oprot.writeI64(struct.ballot);
      }
      if (struct.isSetMax_replica_count()) {
        oprot.writeI32(struct.max_replica_count);
      }
      if (struct.isSetPrimary()) {
        struct.primary.write(oprot);
      }
      if (struct.isSetSecondaries()) {
        {
          oprot.writeI32(struct.secondaries.size());
          for (rpc_address _iter8 : struct.secondaries) {
            _iter8.write(oprot);
          }
        }
      }
      if (struct.isSetLast_drops()) {
        {
          oprot.writeI32(struct.last_drops.size());
          for (rpc_address _iter9 : struct.last_drops) {
            _iter9.write(oprot);
          }
        }
      }
      if (struct.isSetLast_committed_decree()) {
        oprot.writeI64(struct.last_committed_decree);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, partition_configuration struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot =
          (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(7);
      if (incoming.get(0)) {
        struct.pid = new gpid();
        struct.pid.read(iprot);
        struct.setPidIsSet(true);
      }
      if (incoming.get(1)) {
        struct.ballot = iprot.readI64();
        struct.setBallotIsSet(true);
      }
      if (incoming.get(2)) {
        struct.max_replica_count = iprot.readI32();
        struct.setMax_replica_countIsSet(true);
      }
      if (incoming.get(3)) {
        struct.primary = new rpc_address();
        struct.primary.read(iprot);
        struct.setPrimaryIsSet(true);
      }
      if (incoming.get(4)) {
        {
          org.apache.thrift.protocol.TList _list10 =
              new org.apache.thrift.protocol.TList(
                  org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.secondaries = new java.util.ArrayList<rpc_address>(_list10.size);
          rpc_address _elem11;
          for (int _i12 = 0; _i12 < _list10.size; ++_i12) {
            _elem11 = new rpc_address();
            _elem11.read(iprot);
            struct.secondaries.add(_elem11);
          }
        }
        struct.setSecondariesIsSet(true);
      }
      if (incoming.get(5)) {
        {
          org.apache.thrift.protocol.TList _list13 =
              new org.apache.thrift.protocol.TList(
                  org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.last_drops = new java.util.ArrayList<rpc_address>(_list13.size);
          rpc_address _elem14;
          for (int _i15 = 0; _i15 < _list13.size; ++_i15) {
            _elem14 = new rpc_address();
            _elem14.read(iprot);
            struct.last_drops.add(_elem14);
          }
        }
        struct.setLast_dropsIsSet(true);
      }
      if (incoming.get(6)) {
        struct.last_committed_decree = iprot.readI64();
        struct.setLast_committed_decreeIsSet(true);
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(
      org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme())
            ? STANDARD_SCHEME_FACTORY
            : TUPLE_SCHEME_FACTORY)
        .getScheme();
  }
}
